package fun.chutianshu.competitionmanagement.daomapper;

import fun.chutianshu.competitionmanagement.pojo.Student;
import fun.chutianshu.competitionmanagement.pojo.UserInfo;
import org.apache.ibatis.jdbc.SQL;

public class SqlProvider {
    public String updateUserInfoSql(UserInfo userInfo){
        return new SQL(){
            {
                UPDATE("userInfo");
                if (null != userInfo.getUserName()) {
                    SET("user_name=#{userName}");
                }
                SET("user_pwd=#{userPwd}");
                SET("user_role=#{userRole}");
                WHERE("user_id=#{userId}");
            }
        }.toString();

    }

    public String updateStudentSql(Student student){
        return new SQL(){
            {
                UPDATE("student");
                if (null != student.getStuName()) {
                    SET("stu_name=#{stuName}");
                }
                SET("sut_gender=#{stuGender}");
                SET("phone_num=#{phoneNum}");
                SET("birthday=#{birthday}");
                SET("photo=#{photo}");
                SET("weixin_num=#{weixinNum}");
                SET("class_id=#{classId}");
                WHERE("stu_code=#{stuCode}");
            }
        }.toString();

    }
}
